package com.hunray.rent.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.validation.constraints.NotNull;
@Entity
@Table(name="t_device")
public class Device implements Serializable{

	private static final long serialVersionUID = 1L;
	
	private Integer id;
	
	private String no;
	
	private String name;
	
	private String model;//型号
	
	private String brand;//品牌
	
	private int status;//正常，损坏
	
	private Boolean free;//是否可租用
	
	private Boolean lost;//是否丢失
	
	private List<DeviceRent> deviceRents;
	
	private List<DeviceBack> deviceBacks;
	
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator="tg_device")
	@TableGenerator(name="tg_device",table="t_id",pkColumnName="f_table",pkColumnValue="t_product",valueColumnName="f_id",initialValue=1,allocationSize=1)
	@Column(name="f_id")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name="f_no",nullable=false,unique=true)
	@NotNull
	public String getNo() {
		return no;
	}

	public void setNo(String no) {
		this.no = no;
	}
	@Column(name="f_name",nullable=false,unique=true)
	@NotNull
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name="f_model")
	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}
	@Column(name="f_brand")
	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}

	@Column(name="f_status",length=2)
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@Column(name="f_is_free")
	public Boolean getFree() {
		return free;
	}

	public void setFree(Boolean free) {
		this.free = free;
	}
	@Column(name="f_is_lost")
	public Boolean getLost() {
		return lost;
	}

	public void setLost(Boolean lost) {
		this.lost = lost;
	}
	@OneToMany(fetch=FetchType.LAZY,mappedBy="device")
	public List<DeviceRent> getDeviceRents() {
		return deviceRents;
	}

	public void setDeviceRents(List<DeviceRent> deviceRents) {
		this.deviceRents = deviceRents;
	}
	@OneToMany(fetch=FetchType.LAZY,mappedBy="device")
	public List<DeviceBack> getDeviceBacks() {
		return deviceBacks;
	}

	public void setDeviceBacks(List<DeviceBack> deviceBacks) {
		this.deviceBacks = deviceBacks;
	}

	
	
	
}
